﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TVBox源合并工具.DTO
{
    public class Source
    {
        #region 构造函数
        public Source() { }

        public Source(int index, string name, string path, int type)
        {
            this.Index = index;
            this.Name = name;
            this.Path = path;
            this.Type = type;
            this.FileName = index.ToString() + ".json";
            this.JarName = index.ToString() + ".jar";

            //取得Url，用于配置中的本地文件下载
            if (type == 0)
            {
                string[] temp = this.Path.Split('?');
                if (temp.Length > 0)
                {
                    string url = temp[0];
                    url = url.Substring(0, url.LastIndexOf("/"));
                    this.Url = url;
                }
            }
        }
        #endregion

        /// <summary>
        /// 序号
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string FileName { get; set; }

        /// <summary>
        /// Jar文件名称(spider)
        /// </summary>
        public string JarName { get; set; }

        /// <summary>
        /// JarMd5(spider)
        /// </summary>
        public string JarMd5 { get; set; }

        /// <summary>
        /// Jar文件路径
        /// </summary>
        public string JarPath { get; set; }

        /// <summary>
        /// 路径
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 网址
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// 类型(0:网址 1:文件)
        /// </summary>
        public int Type { get; set; }
    }
}
